package cn.wolfcode.luowowo.controller;

import cn.wolfcode.luowowo.domain.Banner;
import cn.wolfcode.luowowo.service.IBannerService;
import cn.wolfcode.luowowo.util.JsonResult;
import cn.wolfcode.luowowo.util.UploadUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 图片上传控制器
 */
@RestController
@RequestMapping("indexs")
public class IndexController {

    @Autowired
    private IBannerService bannerService;

    @RequestMapping("/banners/travel")
    public Object travel(){

        List<Banner> list =  bannerService.queryByTop5ByType(Banner.TYPE_TRAVEL);
        return JsonResult.success(list);
    }

    @RequestMapping("/banners/strategy")
    public Object strategy(){

        List<Banner> list =  bannerService.queryByTop5ByType(Banner.TYPE_STRATEGY);
        if(list.size()>0){
            return JsonResult.success(list.get(0));
        }
        return null;
    }


}
